***********************************************************************.
* PATCHFILE FOR CORRECTING ERRATA IN ALLBUS/GGSS 1980-86              *.
*                                                                     *.
*                                                                     *.
* FOR USE WITH RELEASE 1.0.0, doi:10.4232/1.1335                      *.
*                                                                     *.
*                                                                     *.
* THIS PATCH RECODES MISSING VALUE CODES TO INTEGERS FOR VARIABLES    *.
* WITH DECIMAL PLACES AND ASSIGNS LABELS TO THEM		              *.
*                                                                     *.
* ALSO, THIS PATCH CORRECTS WEIGHT VARIABLE v691 AND RECODES          *.
* CASES LACKING INFORMATION TO MISSING             			          *.				                                                                                      * 								      *.
***********************************************************************.

use "$widowsallbus/data/ZA1335_v1-0-0.dta", clear
notes drop _all

*	v691, TRANSFORMATIONSGEWICHT 
* 	DATA CORRECTION: RECODING CASES LACKING INFORMATION TO MISSING (.a "KEINE ANGABE")


recode v691 (99.99999 = .a)
capture label define Gewichte .a "KEINE ANGABE"
label values v691 Gewichte
foreach var in v691{
note `var' : TS CASES LACKING INFORMATION ABOUT HOUSEHOLD SIZE WERE SET TO MISSING
}


*RECODING VARIABLES AND ASSIGNING LABELS TO MISSING VALUES FOR VARIABLES WITH DECIMAL PLACES
foreach var in v231{
replace `var' = 99 if `var' ==99.99
notes `var': TS CODES FOR MISSING VALUES DIFFER FROM SPSS DATA SET
}


foreach var in v231{
capture label define `var' 0 "NICHT GEBILDET", modify
capture label define `var' 99 "NICHT ENTHALTEN", modify
label values `var' `var'
}

foreach var in v258{
replace `var' = 99 if `var' ==99.999
notes `var': TS CODES FOR MISSING VALUES DIFFER FROM SPSS DATA SET
}

foreach var in v258{
capture label define `var' 0 "NICHT ERHOBEN", modify
capture label define `var' 99 "NICHT ENTHALTEN", modify
label values `var' `var'
}



foreach var in v243{
replace `var' = 998 if `var' ==999.8
replace `var' = 999 if `var' ==999.9
notes `var': TS CODES FOR MISSING VALUES DIFFER FROM SPSS DATA SET
}


foreach var in v243{
capture label define `var' 0 "TNZ", modify
capture label define `var' 998 "WN", add
capture label define `var' 999 "KA", modify
label values `var' `var'
}



foreach var in v262 v263 v558 v568 v574{
replace `var' = 997 if `var' ==999.7
replace `var' = 998 if `var' ==999.8
replace `var' = 999 if `var' ==999.9
notes `var': TS CODES FOR MISSING VALUES DIFFER FROM SPSS DATA SET
}


foreach var in v262 v263 v558 v568 v574{
capture label define `var' 999 "KA", replace
capture label define `var' 0 "TNZ", modify
capture label define `var' 997 "VERWEIGERT", add
capture label define `var' 998 "WN", add
label values `var' `var'
}




note: TS CODES AND LABELS OF MISSING VALUES UPDATED FOR VARIABLES WITH DECIMAL PLACES: ///
PLEASE NOTE THAT FOR THESE VARIABLES THE STATA CODES MIGHT BE DIFFERENT FROM THOSE OF THE SPSS DATA SET

save "$widowsallbus/processed/ZA1335_v1-0-0_patched.dta", replace
